using UnityEngine;
using System.Collections;

public class BarWave : MonoBehaviour {
	
	public float amount;
	public bool isReady;

	void Update () 
	{
		if(isReady)
		{
			transform.localScale = new Vector3(transform.localScale.x - (amount*Time.deltaTime),transform.localScale.y,transform.localScale.z);
		}
		
		if(transform.localScale.x <= 0)
		{
			transform.localScale = new Vector3 (0,transform.localScale.y,transform.localScale.z);
			isReady = false;
		}
		
		if(transform.localScale.x >= 1)
		{
			transform.localScale = new Vector3 (1,transform.localScale.y,transform.localScale.z);
			isReady = false;
		}

	}
	
	void Cancel()
	{
		isReady = false;
	}
	
	void Begin()
	{
		isReady = true;
	}
	
	void Begin(float newAmount)
	{
		isReady = true;
		amount = newAmount;
	}
			
}
